package com.song.su.controller;

import com.song.su.mapper.AdminMapper;
import com.song.su.mapper.CommentMapper;
import com.song.su.model.CommentUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigInteger;
import java.util.List;

@Controller
public class AdminController {
    @Autowired
    CommentMapper commentMapper;


    @GetMapping("/admin")
    public String adminLogin(Model model){
        List<CommentUser> commentUsers = commentMapper.findAll();
        model.addAttribute("commentUsers",commentUsers);
        return "admin";
    }

    @GetMapping("/admin1")
    public String postAdmin(@RequestParam(name = "id")int id
                            ){
        commentMapper.delectColumn(id);
        return "redirect:/admin";

    }

}
